<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>考试页面</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .header {
            width: 100%;
            padding: 1rem;
            background-color: #007bff;
            color: white;
            display: flex;
            justify-content: flex-end;
            position: fixed;
            top: 0;
            right: 0;
            box-sizing: border-box;
        }

        .header span {
            font-size: 1.25rem;
        }

        .container {
            margin-top: 80px; /* 保证内容不会被固定的header遮挡 */
            width: 100%;
            max-width: 800px;
            padding: 2rem;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        h1 {
            font-size: 2rem;
            margin-bottom: 1.5rem;
            color: #333;
            text-align: center;
        }

        .exam-content {
            margin-bottom: 2rem;
        }

        button {
            padding: 0.75rem 1.5rem;
            font-size: 1.25rem;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            background-color: #007bff;
            color: white;
        }

        button:hover {
            background-color: #0056b3;
        }
    </style>
    <script>
        let remainingTime = {{ remaining_time }};
        let interval;

        function startTimer() {
            const timerElement = document.getElementById('timer');
            interval = setInterval(() => {
                if (remainingTime > 0) {
                    remainingTime--;
                    const minutes = Math.floor(remainingTime / 60);
                    const seconds = remainingTime % 60;
                    timerElement.textContent = `剩余时间: ${minutes} 分钟 ${seconds} 秒`;
                } else {
                    clearInterval(interval);
                    alert("考试时间到，系统将自动提交。");
                    document.getElementById('examForm').submit();
                }
            }, 1000);
        }

        window.onload = startTimer;

        function submitExam() {
            clearInterval(interval);
            document.getElementById('examForm').submit();
        }
    </script>
</head>
<body>
    <div class="header">
        <span id="timer">剩余时间: 正在计算...</span>
    </div>

    <div class="container">
        <h1>考试页面</h1>
        <div class="exam-content">
            <!-- 在这里添加考试题目内容 -->
            <p>考试题目示例：这是一个样例题目。请在此处填写您的答案。</p>
        </div>

        <form id="examForm" method="POST" action="{{ url_for('submit_exam', class_name=class_name, exam_name=exam_name) }}">
            <button type="button" onclick="submitExam()">提交考试</button>
        </form>
    </div>
</body>
</html>
